<?php

	include("../config.php");
	include(INCLUDEDIR."core.php");
	
	db::Connect();
	
	if(!isset($_GET['term'])) exit();
	$q = sanitizar($_GET['term']);
	
	
	$filtros = db::SearchText($q,"personas");
	
	$query = "	SELECT personas.id_persona, personas.nombre_persona, personas.email
				FROM personas   
				WHERE $filtros AND personas.inactivo = '0' and es_dondeaprendo = '1'";
	$result = mysql_query($query);
	$posts = array();
	if($result && mysql_num_rows($result)>0) {
		while($row = mysql_fetch_assoc($result)) {
			$posts[] = array( "id" => $row['id_persona'], 
					"label" => $row['nombre_persona']." (".$row['email'].")", 
					"value" => $row['nombre_persona']);
			
		}
	}
	
	echo(json_encode($posts));
?>